"use strict";
const axios = require('axios');
const config = require('./config')
const fs = require('fs')

class utils {
  /**
 * 读取文件
 * @param {string} filePath 
 */
  readFile(filePath) {
    return new Promise((resolve, reject) => {
      try {
        fs.readFile(filePath, 'utf8', function (error, data) {

          console.log('readFileerror', JSON.stringify(error))
          if (error || data === undefined) {
            reject({
              status: false,
              message: '读取文件失败'
            })
          }

          resolve({
            status: true,
            message: 'ok',
            data
          })

        })
      } catch (error) {
        reject({
          status: false,
          message: '读取文件失败'
        })
      }
    })
  }
}

module.exports = new utils()